import React, { Component } from "react";
import PubSub from "pubsub-js";
import Search from "./search/index";
import { NavLink, Route } from "react-router-dom";
export default class B extends Component {
  state = {
    name: "周三",
    age: 18,
  };
  
  componentDidMount() {
    // 接收消息
    PubSub.subscribe("pubsub", (data) => {
      console.log(data);
    });
  }
  render() {
    return (
      <div>
        <h3>search传参</h3>
        <hr />
        <NavLink
          to={`/home/b/search?name=${this.state.name}&age=${this.state.age}`}
        >
          search
        </NavLink>
        <hr />
        <Route path="/home/b/search" component={Search}></Route>
      </div>
    );
  }
}
